package com.usian.yygh.controller.api;

import com.usian.yygh.common.result.Result;
import com.usian.yygh.model.hosp.Hospital;
import com.usian.yygh.service.HospitalService;
import com.usian.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author:WGG
 * @Date 2023年01月12日 15:01
 */
//@CrossOrigin
@Api(tags = "医院管理")
@RestController
@RequestMapping("/admin/hosp/hospital")
public class ApiHospController {


    @Autowired
    private HospitalService hospitalService;

    /**
     * 获取分页列表
     * @param page
     * @param limit
     * @param hospitalQueryVo
     * @return
     */
        @ApiOperation(value = "获取分页列表")
        @GetMapping("/findHospList/{page}/{limit}")
        public Result index(
                @PathVariable Integer page,
                @PathVariable Integer limit,
                HospitalQueryVo hospitalQueryVo) {
            //显示上线的医院
            //hospitalQueryVo.setStatus(1);
            Page<Hospital> pageModel = hospitalService.selectHospPage(page, limit, hospitalQueryVo);
            return Result.ok(pageModel);
        }

    /**
     * 根据医院名称获取医院列表
     * @param hosname
     * @return
     */
    @ApiOperation(value = "根据医院名称获取医院列表")
    @GetMapping("findByHosname/{hosname}")
    public Result findByHosname(
            @ApiParam(name = "hosname", value = "医院名称", required = true)
            @PathVariable String hosname) {
        return Result.ok(hospitalService.findByHosname(hosname));
    }
    }

